package com.zr.rocketmq.controller;

import com.zr.rocketmq.producer.OrderMessageProducer;
import com.zr.rocketmq.producer.TransactionOrderProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orders")
public class OrderController {

    @Autowired
    private OrderMessageProducer orderMessageProducer;
    
    @Autowired
    private TransactionOrderProducer transactionOrderProducer;

    /**
     * 发送普通订单消息
     */
    @GetMapping("/send")
    public String sendOrderMessage() {
        orderMessageProducer.sendOrderMessage();
        return "普通订单消息发送成功";
    }

    /**
     * 发送延迟订单消息
     */
    @GetMapping("/sendDelay")
    public String sendDelayOrderMessage() {
        orderMessageProducer.sendDelayOrderMessage();
        return "延迟订单消息发送成功";
    }

    /**
     * 发送事务订单消息
     */
    @GetMapping("/sendTransaction")
    public String sendTransactionOrderMessage() {
        transactionOrderProducer.sendTransactionOrderMessage();
        return "事务订单消息发送成功";
    }
}
